<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="模具编码">
              <a-input @blur="loadVersions()" @change="moldCodeChange()" allow-clear placeholder="请输入模具编号" v-model="queryParam.moldCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="4">
            <a-form-item label="版本">
              <a-select
                @focus="isVersions(queryParam.moldCode)"
                style="width: 150px"
                placeholder="请选择版本"
                v-model="queryParam.version"
                allowClear
              >
                <a-select-option v-for="(item, index) in versions" :key="index" :value="item.value">
                  {{ item.text }}
                </a-select-option>
              </a-select>
              <!-- <a-input placeholder="请输入材料" v-model="queryParam.material"></a-input> -->
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a> -->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd2" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订购BOM')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query
        :fieldList="superFieldList"
        ref="superQueryModal"
        @handleSuperQuery="handleSuperQuery"
      ></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>

      <!-- 规定显示隐藏的表头 -->
      <a-button style="margin-left: 8px" @click="btnShowHideBom"> {{ showHideBom }}</a-button>

      <!-- 选择显示隐藏表头 -->
      <a-dropdown :trigger="['click']" style="margin-bottom: 10px" v-model="DropdownVisible">
        <a-menu slot="overlay">
          <a-menu-item v-for="(item, index) in columns" :key="index"
            ><a-checkbox
              :checked="item.show"
              @change="
                (e) => {
                  columnsCheck(e.target.checked, columns, index)
                }
              "
              >{{ item.title }}</a-checkbox
            ></a-menu-item
          >
        </a-menu>
        <a-button style="margin-left: 8px"> 勾选需要显示的列<a-icon type="down" /> </a-button>
      </a-dropdown>

      <!-- 隐藏显示功能栏 -->
      <a-button style="margin-left: 8px" @click="btnShowFun"> {{ showHideBomFun }}</a-button>

      <!-- 选择固定表头 -->
      <!-- <a-dropdown :trigger="['click']" style="margin-bottom: 10px" v-model="DropdownVisibleHeard">
        <a-menu slot="overlay">
          <a-menu-item v-for="(item, index) in columns" :key="index"
            ><a-checkbox
            :checked="item.fixed == 'left' || item.fixed == 'right'"
              @change="
                (e) => {
                  columnsCheckHeard(e.target.checked, columns, index)
                }
              "
              >{{ item.title }}</a-checkbox
            ></a-menu-item
          >
        </a-menu>
        <a-button style="margin-left: 8px"> 勾选需要固定的列 <a-icon type="down" /> </a-button>
      </a-dropdown> -->

      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>

      <!-- 批量新增操作 -->
      <a-button v-if="selectedRowKeys.length > 0" style="margin-left: 8px" @click="batchUpdate">更新</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: xWith, y: yHigh }"
        bordered
        rowKey="id"
        :columns="
          columns.filter((col, num) => {
            if (col.show) {
              return col
            }
          })
        "
        :dataSource="dataSource"
        :pagination="ipagination"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <!-- <template v-for="col in ['chineseName', 'englishName', 'partSpecification']"
                :slot="col"
                slot-scope="text"
                >
                <sapn :key="col" style="white-space: pre-line">
                  {{text}}
                </sapn>
      </template> -->

      <!-- 设计BOM-serialNumber-序号 -->
      <div slot="serialNumber" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        
        <!-- 设计BOM-partName-零件名 -->
        <div slot="partName" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        <!-- 设计BOM-chineseName中文名 -->
        <div slot="chineseName" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>
        <!-- 设计BOM-englishName英文名 -->
        <div slot="englishName" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>
        <!-- 设计BOM-零件规格 -->
        <div slot="partSpecification" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>
        <!-- 设计BOM-材料 -->
        <div slot="material" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        <!-- 设计BOM-备注 -->
        <div slot="remark" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        <!-- 订购BOM-designSerialNo-NO -->
        <div slot="designSerialNo" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>
        <!-- 订购BOM-materialCode-物料编码 -->
        <div slot="materialCode" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        <!-- 订购BOM-materialName-物料名称 -->
        <div slot="materialName" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        <!-- 订购BOM-specifications-规格 -->
        <div slot="specifications" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>

        <!-- 订购BOM-specificationsDescription-规格说明 -->
        <div slot="specificationsDescription" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>
        <!-- 订购BOM-purchaseRequisitionRemarks-请购备注 -->
        <!-- <div
                slot="purchaseRequisitionRemarks"
                slot-scope="text">
                <span style="white-space: pre-line">
                  {{text}}
                </span>
              </div> -->
        <template slot="purchaseRequisitionRemarks" slot-scope="text, record">
          <a-textarea
            style="width: 130px; text-align: left"
            v-model="record.purchaseRequisitionRemarks"
            @blur="handleBlur($event, record)"
            @change="handleChange(record)"
            @keyup.enter.native="$event.target.blur"
            auto-size
          />
          <!-- <a-input
          style="width: 50px;text-align: center;"
            v-model="record.purchaseRequisitionRemarks"
            @blur="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input> -->
        </template>

        <!-- 订购BOM-t100DemandDate-T100需求日期 -->
        <!-- <div
                slot="t100DemandDate"
                slot-scope="text">
                <span style="white-space: pre-line">
                  {{text}}
                </span>
              </div> -->
        <template slot="t100DemandDate" slot-scope="text, record">
          <a-date-picker
            placeholder=""
            style="width: 120px"
            :format="dateFormat"
            :valueFormat="dateFormat"
            v-model="record.t100DemandDate"
            @change="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          />
          <!-- <a-input
            style="width: 100px; text-align: center"
            v-model="record.t100DemandDate"
            @blur="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input> -->
        </template>

        <!-- 可编辑插槽--designNum数量 -->
        <template slot="designNum" slot-scope="text, record">
          <a-input
            style="width: 50px; text-align: center"
            v-model="record.designNum"
            @blur="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input>
        </template>

        <!-- 可编辑插槽--erpCode ERP代码 -->
        <template slot="erpCode" slot-scope="text, record">
          <!-- v-if="selectedRowKeys.indexOf(record.id) != -1" -->
          <a-input
            style="width: 60px"
            v-model="record.erpCode"
            @blur="blurpartName($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input>
          <!-- <span v-else>{{text}}-{{record.id}}</span> -->
        </template>

        <!-- 下拉选项插槽--bulkPartsType 散件类型 -->
        <template slot="bulkPartsType" slot-scope="text, record">
          <!-- <a-input v-model="record.bulkPartsType" @blur="blurpartName($event, record)"></a-input> -->

          <a-select style="width: 100px" @change="handleBlur($event, record)" v-model="record.bulkPartsType" allowClear>
            <a-select-option v-for="(item, index) in bulkPartsTypeList" :key="index" :value="item.value">
              {{ item.text }}
            </a-select-option>
          </a-select>
        </template>

        <!-- 可编辑插槽--partsType部件编号/零件名 -->
        <template slot="partsType" slot-scope="text, record">
          <a-input
            style="width: 100px"
            v-model="record.partsType"
            @blur="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input>
        </template>

        <!-- 可编辑插槽--withoutAllowanceDimension未加余量的尺寸 -->
        <template slot="withoutAllowanceDimension" slot-scope="text, record">
          <a-input
            style="width: 170px"
            v-model="record.withoutAllowanceDimension"
            @blur="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input>
        </template>

        <!-- 下拉选项插槽--mixMaterialsAndNotOrder拼料和不订料 -->
        <template slot="mixMaterialsAndNotOrder" slot-scope="text, record">
          <!-- <a-input v-model="record.mixMaterialsAndNotOrder" @blur="blurpartName($event, record)"></a-input> -->

          <a-select
            style="width: 80px"
            @change="handleBlur($event, record)"
            v-model="record.mixMaterialsAndNotOrder"
            allowClear
          >
            <a-select-option v-for="(item, index) in mixMaterialsAndNotOrderList" :key="index" :value="item.value">
              {{ item.text }}
            </a-select-option>
          </a-select>
        </template>

        <!-- 下拉选项插槽--rawMaterialsAndAccessories原材料/配件 -->
        <template slot="rawMaterialsAndAccessories" slot-scope="text, record">
          <!-- <a-input v-model="record.rawMaterialsAndAccessories" @blur="blurpartName($event, record)"></a-input>-->
          <a-select
            style="width: 80px"
            @change="handleBlur($event, record)"
            v-model="record.rawMaterialsAndAccessories"
            allowClear
          >
            <a-select-option v-for="(item, index) in rawMaterialsAndAccessoriesList" :key="index" :value="item.value">
              {{ item.text }}
            </a-select-option>
          </a-select>
        </template>

        <!-- 订购BOM-t100Units-T100单位 -->
        <div slot="t100Units" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div>
        <!-- 订购BOM-可编辑-t100MoldNo-T100模具编号 -->
        <template slot="t100MoldNo" slot-scope="text, record">
          <a-input
            style="width: 110px"
            v-model="record.t100MoldNo"
            @blur="handleBlur($event, record)"
            @keyup.enter.native="$event.target.blur"
          ></a-input>
        </template>

        <!-- <div slot="t100MoldNo" slot-scope="text">
          <span style="white-space: pre-line">
            {{ text }}
          </span>
        </div> -->

        <!-- bom状态插槽 -->
        <template slot="bomStatus" slot-scope="text">
          <a-tag v-if="text == '1'" color="blue">新增</a-tag>
          <a-tag v-if="text == '2'" color="red">变更</a-tag>
          <a-tag v-if="text == '3'">不变</a-tag>
          <a-tag v-if="text == '4'" color="purple">变更</a-tag>
          <!-- <span v-if="text == '1'">新增</span>
          <span v-if="text == '2'">变更</span>
          <span v-if="text == '3'">取消</span> -->
        </template>

        <!-- 转益模的状态插槽 -->
        <template slot="transferBenefitModelStatus" slot-scope="text">
          <span v-if="text == '1'">未转</span>
          <span v-if="text == '2'">已转</span>
        </template>

        <!-- 是否删除的状态插槽 -->
        <template slot="isDelete" slot-scope="text">
          <a-tag v-if="text == '0'" color="blue">正常</a-tag>
          <a-tag v-if="text == '1'" color="orange">删除</a-tag>
          <!-- <span v-if="text == '0'">正常</span> -->
          <!-- <span v-if="text == '1'">删除</span> -->
          <!-- <span v-if="text == null">null</span> -->
        </template>

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <!-- 操作插槽 -->
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <!-- <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item> -->
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>

    <ch-order-bom-modal ref="modalForm" @ok="modalFormOk"></ch-order-bom-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ChOrderBomModal from './modules/ChOrderBomModal'
import { getAction } from '../../api/manage'

export default {
  name: 'ChOrderBomList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    ChOrderBomModal,
  },
  data() {
    return {
      xWith: '',
      yHigh: 700,
      description: '订购BOM管理页面',
      // 日期格式
      dateFormat: 'YYYY/MM/DD',
      // 版本
      versions: [],
      // 下拉选择显示隐藏表头
      DropdownVisible: false,
      // 下拉选择设置固定头
      //DropdownVisibleHeard: false,
      // 散件类型
      bulkPartsType: '',
      // 散件类型下拉数据
      bulkPartsTypeList: [],
      // 拼料和不订料
      mixMaterialsAndNotOrder: '',
      // 拼料和不订料下拉数据
      mixMaterialsAndNotOrderList: [],
      //原材料/配件
      rawMaterialsAndAccessories: '',
      //原材料/配件下拉数据
      rawMaterialsAndAccessoriesList: [],
      // 固定头颜色
      color: '#f9f9f9',
      // 表头
      columns: [
        // {
        //   title: '#',
        //   dataIndex: '',
        //   key: 'rowIndex',
        //   width: 30,
        //   fixed: 'left',
        //   align: 'center',
        //   customRender: function (t, r, index) {
        //     return parseInt(index) + 1
        //   },
        //   show: true,
        // },
        {
          title: '序号',
          width: 60,
          fixed: 'left',
          align: 'center',
          dataIndex: 'serialNumber',
          scopedSlots: { customRender: 'serialNumber' },
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          show: true,
        },
        {
          title: '零件名',
          width: 60,
          fixed: 'left',
          align: 'center',
          dataIndex: 'partName',
          scopedSlots: { customRender: 'partName' },
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          show: true,
        },
        {
          title: '中文名',
          width: 80,
          fixed: 'left',
          align: 'center',
          dataIndex: 'chineseName',
          scopedSlots: { customRender: 'chineseName' },
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          show: true,
        },
        {
          title: '英文名',
          width: 80,
          fixed: 'left',
          align: 'center',
          dataIndex: 'englishName',
          scopedSlots: { customRender: 'englishName' },
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          show: true,
        },
        {
          title: '零件规格',
          width: 100,
          fixed: 'left',
          align: 'center',
          dataIndex: 'partSpecification',
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          scopedSlots: { customRender: 'partSpecification' },
          show: true,
        },
        {
          title: '材料',
          width: 50,
          fixed: 'left',
          align: 'center',
          dataIndex: 'material',
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          scopedSlots: { customRender: 'material' },
          show: true,
        },
        {
          title: '数量',
          width: 50,
          fixed: 'left',
          align: 'center',
          dataIndex: 'number',
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          show: true,
        },
        {
          title: '备注',
          width: 80,
          fixed: 'left',
          align: 'center',
          dataIndex: 'remark',
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': this.color,
              },
            }
          },
          scopedSlots: { customRender: 'remark' },
          show: true,
        },
        // {
        //   title: 'bom状态（1.新增2.变更3.取消）',
        //   align: 'center',
        //   dataIndex: 'bomStatus',
        //   scopedSlots: { customRender: 'bomStatus' },
        //   show: true,
        // },
        // {
        //   title: '转益模的状态（1.未转2.已转）',
        //   align: 'center',
        //   dataIndex: 'transferBenefitModelStatus',
        //   scopedSlots: { customRender: 'transferBenefitModelStatus' },
        //   show: true,
        // },
        // {
        //   title: '模具设计BOM主表id',
        //   align: 'center',
        //   dataIndex: 'chDesignBomMasterId',
        //   show: true,
        // },
        // {
        //   title: '是否删除（0.正常1.删除）',
        //   align: 'center',
        //   dataIndex: 'isDelete',
        //   scopedSlots: { customRender: 'isDelete' },
        //   show: true,
        // },
        {
          title: 'NO',
          width: 40,
          align: 'center',
          fixed: '',
          dataIndex: 'designSerialNo',
          scopedSlots: { customRender: 'designSerialNo' },
          show: true,
        },
        {
          title: '物料编码',
          width: 70,
          align: 'center',
          dataIndex: 'materialCode',
          scopedSlots: { customRender: 'materialCode' },
          show: true,
        },
        {
          title: '物料名称',
          width: 70,
          align: 'center',
          dataIndex: 'materialName',
          scopedSlots: { customRender: 'materialName' },
          show: true,
        },
        {
          title: '规格',
          width: 100,
          align: 'center',
          dataIndex: 'specifications',
          scopedSlots: { customRender: 'specifications' },
          show: true,
        },
        {
          title: '规格说明',
          width: 150,
          align: 'center',
          dataIndex: 'specificationsDescription',
          scopedSlots: { customRender: 'specificationsDescription' },
          show: true,
        },
        {
          title: '重量(KG)',
          width: 80,
          align: 'center',
          dataIndex: 'weight',
          show: true,
        },
        {
          title: '软硬料',
          width: 60,
          align: 'center',
          dataIndex: 'softAndHardMaterials',
          show: true,
        },
        // {
        //   title: '精毛料',
        //   width: 60,
        //   align: 'center',
        //   dataIndex: 'fineWool',
        //   show: true,
        // },
        {
          title: '数量',
          width: 70,
          align: 'center',
          dataIndex: 'designNum',
          scopedSlots: { customRender: 'designNum' },
          show: true,
        },
        {
          title: '请购备注',
          width: 150,
          align: 'center',
          dataIndex: 'purchaseRequisitionRemarks',
          scopedSlots: { customRender: 'purchaseRequisitionRemarks' },
          show: true,
        },
        {
          title: 'ERP代码',
          width: 80,
          align: 'center',
          dataIndex: 'erpCode',
          scopedSlots: { customRender: 'erpCode' },
          show: true,
        },
        {
          title: '未加余量的尺寸',
          width: 200,
          align: 'center',
          dataIndex: 'withoutAllowanceDimension',
          scopedSlots: { customRender: 'withoutAllowanceDimension' },
          show: true,
        },
        {
          title: '原材料/配件',
          width: 120,
          align: 'center',
          dataIndex: 'rawMaterialsAndAccessories',
          scopedSlots: { customRender: 'rawMaterialsAndAccessories' },
          show: true,
        },
        {
          title: '散件类型',
          width: 130,
          align: 'center',
          dataIndex: 'bulkPartsType',
          scopedSlots: { customRender: 'bulkPartsType' },
          show: true,
        },
        {
          title: '部件编号/零件名',
          width: 130,
          align: 'center',
          dataIndex: 'partsType',
          scopedSlots: { customRender: 'partsType' },
          show: true,
        },
        {
          title: '拼料和不订料',
          width: 120,
          align: 'center',
          dataIndex: 'mixMaterialsAndNotOrder',
          scopedSlots: { customRender: 'mixMaterialsAndNotOrder' },
          show: true,
        },
        {
          title: '需求日期',
          width: 140,
          align: 'center',
          dataIndex: 't100DemandDate',
          scopedSlots: { customRender: 't100DemandDate' },
          show: true,
        },
        {
          title: 'T100单位',
          width: 80,
          align: 'center',
          dataIndex: 't100Units',
          scopedSlots: { customRender: 't100Units' },
          show: true,
        },
        {
          title: 'T100模具编号',
          width: 130,
          align: 'center',
          dataIndex: 't100MoldNo',
          scopedSlots: { customRender: 't100MoldNo' },
          show: true,
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
          show: true,
        },
      ],
      url: {
        list: '/ch/chOrderBom/list',
        delete: '/ch/chOrderBom/delete',
        deleteBatch: '/ch/chOrderBom/deleteBatch',
        exportXlsUrl: '/ch/chOrderBom/exportXls',
        importExcelUrl: 'ch/chOrderBom/importExcel',

        // 更新路径
        pieceData: '/ch/chOrderBom/edit',
        // 新增路径
        add: '/ch/chOrderBom/add',
        // 订购BOM获取版本集合
        queryVersions: '/ch/chOrderBom/queryVersions',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    // 计算表格的每列的宽度
    this.columns.map((x, i) => {
      if (x.width) {
        this.xWith = (this.xWith + x.width) * 1
      }
    })
    console.log('this.xWith', this.xWith)
    this.xWith = this.xWith
    // 执行按钮
    this.btnShowHideBom()
    this.btnShowFun()

    this.getSuperFieldList()

    this.bulkPartsTypeList = [
      {
        value: '耐磨块',
        text: '耐磨块',
      },
      {
        value: '平衡块',
        text: '平衡块',
      },
      // {
      //   value: '行位压块',
      //   text: '行位压块',
      // },
      {
        value: '导向块',
        text: '导向块',
      },
      {
        value: '方向块',
        text: '方向块',
      },
      {
        value: '方撑头',
        text: '方撑头',
      },
      {
        value: '合并料',
        text: '合并料',
      },
      {
        value: '其它散件',
        text: '其它散件',
      },
    ]
    ;(this.mixMaterialsAndNotOrderList = [
      {
        value: '拼料',
        text: '拼料',
      },
      {
        value: '不订料',
        text: '不订料',
      },
    ]),
      (this.rawMaterialsAndAccessoriesList = [
        {
          value: '原材料',
          text: '原材料',
        },
        {
          value: '配件',
          text: '配件',
        },
      ])
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    // filterOption(input, option) {
    //   return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    // },

    // // 版本
    // loadVersions() {
    //         //查询版本(请求获取)
    //         console.log('this.queryParam.moldCode', this.queryParam.moldCode)
    //         if (this.queryParam.moldCode) {
    //             this.versions = []
    //             getAction(this.url.queryVersions, {
    //                 moldCode: this.queryParam.moldCode
    //             }).then((res) => {
    //                 if (res.code == 200) {
    //                     if (res.result) {
    //                         res.result.forEach((item) => {
    //                             var obj = {}
    //                             obj.value = item
    //                             obj.text = item
    //                             this.versions.push(obj)
    //                         })
    //                     }
    //                     console.log('res111', res)
    //                     console.log('this.versions', this.versions)
    //                 } else {
    //                     // this.$message.error(res.message)
    //                     this.queryParam.version = ''
    //                     this.versions = []
    //                 }
    //             })
    //         } else {
    //             // this.$message.warning('模具编号不能为空')
    //             this.queryParam.version = ''
    //             this.versions = []
    //         }
    //     },
    //     // isVersions
    //     isVersions(value) {
    //         console.log('value', value);
    //         if (!value) {
    //             this.$message.warning('选择版本时模具编号不能为空')
    //         }
    //     },
    //     // moldCodeChange //清空时触发
    //     moldCodeChange() {
    //         if (this.queryParam.moldCode == null || this.queryParam.moldCode == undefined || this.queryParam.moldCode == '') {
    //             this.queryParam.version = ''
    //             this.versions = []
    //         }
    //     },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'int', value: 'serialNumber', text: '序号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'partName', text: '零件名', dictCode: '' })
      fieldList.push({ type: 'string', value: 'chineseName', text: '中文名', dictCode: '' })
      fieldList.push({ type: 'string', value: 'englishName', text: '英文名', dictCode: '' })
      fieldList.push({ type: 'string', value: 'partSpecification', text: '零件规格', dictCode: '' })
      fieldList.push({ type: 'string', value: 'material', text: '材料', dictCode: '' })
      fieldList.push({ type: 'int', value: 'number', text: '数量', dictCode: '' })
      fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
      fieldList.push({ type: 'int', value: 'bomStatus', text: 'bom状态（1.新增2.变更3.取消）', dictCode: '' })
      fieldList.push({
        type: 'int',
        value: 'transferBenefitModelStatus',
        text: '转益模的状态（1.未转2.已转）',
        dictCode: '',
      })
      fieldList.push({ type: 'Blob', value: 'customFields1', text: '自定义字段1', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'customFields2', text: '自定义字段2', dictCode: '' })
      fieldList.push({ type: 'string', value: 'customFields3', text: '自定义字段3', dictCode: '' })
      fieldList.push({ type: 'string', value: 'customFields4', text: '自定义字段4', dictCode: '' })
      fieldList.push({ type: 'string', value: 'customFields5', text: '自定义字段5', dictCode: '' })
      fieldList.push({ type: 'string', value: 'chDesignBomMasterId', text: '模具设计BOM主表id', dictCode: '' })
      fieldList.push({ type: 'int', value: 'isDelete', text: '是否删除（0.正常1.删除）', dictCode: '' })
      fieldList.push({ type: 'string', value: 'designSerialNo', text: '设计BOM序号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'materialCode', text: '物料编码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'materialName', text: '物料名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'specifications', text: '规格', dictCode: '' })
      fieldList.push({ type: 'string', value: 'specificationsDescription', text: '规格说明', dictCode: '' })
      fieldList.push({ type: 'string', value: 'designNum', text: '数量', dictCode: '' })
      fieldList.push({ type: 'string', value: 'purchaseRequisitionRemarks', text: '请购备注', dictCode: '' })
      fieldList.push({ type: 'string', value: 't100DemandDate', text: 'T100需求日期', dictCode: '' })
      fieldList.push({ type: 'string', value: 'erpCode', text: 'ERP代码', dictCode: '' })
      fieldList.push({ type: 'string', value: 'partsType', text: '部件编号/零件名', dictCode: '' })
      fieldList.push({ type: 'string', value: 'withoutAllowanceDimension', text: '未加余量的尺寸', dictCode: '' })
      fieldList.push({ type: 'string', value: 'mixMaterialsAndNotOrder', text: '拼料和不订料', dictCode: '' })
      fieldList.push({ type: 'string', value: 'rawMaterialsAndAccessories', text: '原材料/配件', dictCode: '' })
      fieldList.push({ type: 'string', value: 't100Units', text: 'T100单位', dictCode: '' })
      fieldList.push({ type: 'string', value: 't100MoldNo', text: 'T100模具编号', dictCode: '' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style>
/* 固定列最大高度 */
/* .ant-table-body-inner{
    max-height: 595px !important;
  } */
/* table整体的高度 */
/* .ant-table-scroll {
    height: 700px;
    word-break: break-all;
} */
/* 表内容高度限制 */
/* .ant-table-body{
  height: 600px;
} */

@import '~@assets/less/common.less';
</style>